package com.mav.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class RecordTimeAspect {
    @Around("execution(* com.mav.service.iml.*.*(..))")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        long begin=System.currentTimeMillis();
        Object result = pjp.proceed();
        long end=System.currentTimeMillis();

        log.info("程序用时{}ms",end-begin);
        return result;
    }
}
